
class loading.LoadProcessUI extends MovieClip{
	
	private var root:MovieClip;
	private var loadmc:MovieClip;
	
	private var barColor:Number=0xcccccc;
	private var valueColor:Number=0x000000;
	private var barLength:Number=100;
	
	
	
	public function set BarColor(value:Number){
		this.barColor=value;
	}
	public function get BarColor():Number{
		return barColor;
	}
	
	public function set ValueColor(value:Number){
		this.valueColor=value;
	}
	public function get ValueColor():Number{
		return this.valueColor;
	}
	
	public function set BarLength(value:Number){
		this.barLength=value;
	}
	public function get BarLength():Number{
		return this.barLength;
	}
	
	public function set ll(value:Number){
		this.loadmc.ll=value;
	}
	public function get ll():Number{
		return this.loadmc.ll;
	}
	
	public function set tt(value:Number){
		this.loadmc.tt=value;
	}
	public function get tt():Number{
		return this.loadmc.tt;
	}
	
	public function get _x():Number{
		return this.loadmc._x;
	}
	public function set _x(value:Number){
		this.loadmc._x=value;
	}
	public function get _y():Number{
		return this.loadmc._y;
	}
	public function set _y(value:Number){
		this.loadmc._y=value;
	}
	public function get LoadingMc():MovieClip{
		return this.loadmc;
	}
	
	////////////////////////////////////////////////////////////////////////////
	public function LoadProcessUI(){
		initVars();
	}
	private function initVars(){
		
	}
	public function createLoading(root:MovieClip,level:Number):MovieClip{
		this.root=root;
		if(level==undefined){
			level=root.getNextHighestDepth();
		}
		if(level<0){
			level=0;
		}
		if(root==undefined){
			Say("** error ** loading mc can't be UNDEFINED!!");
			return null;
		}
		
		this.loadmc=root.createEmptyMovieClip("loadmc",level);
		
		this.loadmc.createEmptyMovieClip("loadbar",10);
		this.loadmc.createEmptyMovieClip("loadvalue",11);
		
		this.loadmc.loadbar._x=-barLength/2;
		this.loadmc.loadvalue._x=-50;
		this.loadmc.loadbar.lineStyle(5,barColor,100);
		drawLine(this.loadmc.loadbar,barLength);
		this.loadmc.loadvalue.lineStyle(2,valueColor,100);
		drawLine(this.loadmc.loadvalue,barLength);
		
		this.loadmc.createTextField("bfb",12,-25,1,50,20);
		var ltxt:TextField=this.loadmc.bfb;
		ltxt.type="dynamic";
		ltxt.border=false;
		ltxt.restrict="1234567890%.";
		this.loadmc._alpha=0;
		this.loadmc.ll=0;
		this.loadmc.tt=0;
		this.loadmc.onEnterFrame=this.loadmcOnEnterFrame;
		return this.loadmc;
	}
	private function loadmcOnEnterFrame(){
		var value:Number=int(this["ll"]*10000/this["tt"])/100;
		var txt:String=value.toString()+"%";
		if(this["ll"]>=this["tt"] && this["tt"]>0 && this._alpha>0){
			this._alpha+=int((-10-this._alpha)/4);
			txt="";
		}
		else if(this["tt"]>0 && this["ll"]<this["tt"]){
			this._alpha=100;
			this["loadvalue"]._width=value;
		}
		else if(this["tt"]<=0){
			this._alpha=0;
			txt="";
		}
		if(this["ll"]>=this["tt"] && this["tt"]>0 && this._alpha<=0){
			txt="";
		}
		this["bfb"].text=txt;
	}
	private function drawLine(mc:MovieClip,length:Number){
		mc.moveTo(0,0);
		mc.lineTo(length,0);
	}
	private function Say(o:Object){
		trace(o.toString());
	}
}